package com.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.entity.MerchantBasket;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (MerchantBasket)表数据库访问层
 *
 * @author makejava
 * @since 2020-11-24 10:20:18
 */
@Mapper
public interface MerchantBasketMapper extends BaseMapper<MerchantBasket> {

    List<MerchantBasket> getBasketList(Integer userId);

//    List<Integer> getBasketMerchantList();

//    Integer getBasketListByMerchantRepeatId();

//    List<MerchantBasket> getBasketListByMerchantId(List<Integer> merchantId);

    List<MerchantBasket> getBasketListByMerchantId(@Param("merchantId")Integer merchantId,@Param("userId")Integer userId);

    Integer changeItem(@Param("userId") Integer userId, @Param("merchantBasket") MerchantBasket merchantBasket);

    @Select("SELECT * FROM merchant_basket WHERE goods_id=#{goodsId} AND user_id=#{id} AND merchant_id=#{merchantId}")
    MerchantBasket selectGoodsByGoodsId(@Param("goodsId") Integer goodsId,@Param("id") Integer id,@Param("merchantId") Integer merchantId);

    @Select("SELECT * FROM merchant_basket WHERE user_id=#{userId} AND merchant_id=#{merchantId}")
    List<MerchantBasket> selectCartListByUserId(@Param("userId") Integer userId,@Param("merchantId") Integer merchantId);

    Integer getBasketsCount(Integer userId);

    List<MerchantBasket> totalPay(@Param("userId") Integer userId, @Param("list") List<String> ids);

    Integer deleteItem(@Param("list") List<String> ids);
}
